package com.xiaoluo.a05_countdownlatch;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import java.util.concurrent.CountDownLatch;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final CountDownLatch downLatch = new CountDownLatch(1);
         new Thread() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                downLatch.countDown();
                Log.i(TAG, "iothread");
            }
        }.start();
        try {
            downLatch.await();
            Log.i(TAG, "await");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
